/**
 * Created by tanbingqin on 2020/7/29.
 */
import { messages, deepFullCopy } from "share/common"
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Button, Form, Checkbox, Radio, Row, Col, message, Spin, Select, Affix } from 'antd'
import formService from 'containers/setting/form/form.service'
import Chooser from 'components/chooser'
import errorMessage from 'share/errorMessage'
import AllocationLoanType from 'containers/setting/form/comp/loanType'
import AllocationVendorType from 'containers/setting/form/comp/vendorType'
import chooserData from 'share/chooserData'
import formUtil from 'containers/setting/form/form-util'
import NumberRange from "containers/financial-management/expense-view/component/number-range"
import menuRoute from 'routes/menuRoute'

const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const CheckboxGroup = Checkbox.Group;
const Option = Select.Option;

class LoanProperty extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      disabled: false, //所有表单适用这个属性
      loanDisabled: false, //借款单适用这个属性
      form: {},  //表单信息
      setOfBooksId: '', //表单上的帐套
      priorityValue: {}, //所属组织，启用公司控件value
      priorityRangeValue: {}, //所属组织控件的rangeValue，包含整个对象信息
      paymentTypeList: [], //付款方式下拉列表选择项
      rangeLoanTypeValue: {}, //借款类型控件value
      loanTypeDefaultSelectedList: [], //默认的借款类型
      isHasLoanRelated: false,//是否开启借款单关联申请单的配置
      relatedFormLoading: false,
      relatedFormList: [], //借款单关联申请单配置的可关联的表单
      isReference: false,//关联申请单是否必选
      controlWays: [], //借款金额管控
      singleBottom: 0, //单笔金额下限
      singleTop: 100, //单笔金额上限
      contractEnable: false, //是否关联合同
      contractRequired: false, //关联合同时，是否合同必填
      multiLoanEnable: true, //是否是多行借款
      isShowVendorType: true, //切换收款方类型下供应商是否勾选
      vendorTypeScope: {range: 'ALL', value: []}, //多行借款单的收款方类型配置选择了供应商后的供应商类型选择的配置
      addVenMaster: 'false', //差旅，日常，费用报销单和单行，多行借款单，是否允许新增供应商
    };
    this.formList = menuRoute.getRouteItem('form-list','key'); //表单列表页
  }

  componentDidMount() {
    this.initPaymentTypeList();
    this.initFormData();
    //处理表单属性
    this.initCustomFormPropertyMap();
  };

  initPaymentTypeList = () => {
    //只查询启用的
    formService.getSystemValueList(2105, true).then(resp => {
      let paymentTypeList = [];
      resp.data && resp.data.map(item => {
        paymentTypeList.push({key: item.value, label: item.messageKey});
      });
      this.setState({paymentTypeList});
    });
  };

  initFormData = () => {
    const { form } = this.context;
    this.setState({
      form,
      disabled: !form.edit,
      setOfBooksId: form.setOfBooksId
    });
    //处理所属组织，启用公司
    this.initPriorityValue();
    //处理借款类型
    this.initLoanTypes();
  };

  initLoanTypes = () => {
    const { formType, form } = this.context;
    let rangeLoanTypeValue = {};
    let loanTypeDefaultSelectedList = form.loanTypesDTO.defaultLoanType ? [form.loanTypesDTO.defaultLoanType] : [];
    let loanTypeVisibleScope = form.loanTypesDTO.visibleScope;
    if (formType === 2005) {
      rangeLoanTypeValue.range = loanTypeVisibleScope === 1002 ? 'CUSTOMIZE' : 'DEFAULT';
    }
    if (formType === 2006) {
      rangeLoanTypeValue.range = loanTypeVisibleScope === 1002 ? 'PARTIAL' : 'ALL';
    }
    if (rangeLoanTypeValue.range === 'CUSTOMIZE' || rangeLoanTypeValue.range === 'PARTIAL') {
      rangeLoanTypeValue.value = form.loanTypesDTO.loanTypes || [];
    } else {
      rangeLoanTypeValue.value = [];
    }
    this.setState({rangeLoanTypeValue, loanTypeDefaultSelectedList});
    //1004信用借款单，1005受控借款单
    if (loanTypeVisibleScope === 1004 || loanTypeVisibleScope === 1005) {
      this.setState({loanDisabled: true});
    }
  };

  initCustomFormPropertyMap = () => {
    const { form } = this.context;
    let propertyMap = form.customFormPropertyMap;
    for (let key in propertyMap) {
      if (formUtil.getFieldKey(key, propertyMap[key])) {
        this.props.form.setFieldsValue(formUtil.getFieldKey(key, propertyMap[key]));
      }
      if (formUtil.getStateKey(key, propertyMap[key])) {
        this.setState(formUtil.getStateKey(key, propertyMap[key]));
      }
      if (key === 'loan.application.configuration') {
        let loanConfiguration = JSON.parse(propertyMap[key]);
        if (loanConfiguration.applicationFormOID && loanConfiguration.applicationFormOID.length) {
          //过滤启用，封装成控件可识别的数据格式
          this.setState({relatedFormLoading: true});
          formService.getFormIsEnable(loanConfiguration.applicationFormOID).then(res => {
            this.setState({relatedFormLoading: false});
            if (res.data && res.data.length) {
              let relatedFormList = [];
              res.data.map(relatedForm => {
                relatedFormList.push({formName: relatedForm.formName, formOID: relatedForm.formOID});
              });
              this.setState({relatedFormList: relatedFormList});
            }
          });
        }
        this.setState({
          outApplicationAmount: loanConfiguration.outApplicationAmount,
          isReference: loanConfiguration.isReference,
          relatedApplicationType: loanConfiguration.applicationType ? loanConfiguration.applicationType : null,
          isHasLoanRelated: !loanConfiguration.notLink
        });
      }
      if (key === 'payee.vendor.type') {
        let vendorTypeScopeConfig = JSON.parse(propertyMap[key]);
        let valueList = [];
        vendorTypeScopeConfig.typeList && vendorTypeScopeConfig.typeList.forEach(item => {
          valueList.push({id: item});
        });
        this.setState({
          vendorTypeScope: {
            range: vendorTypeScopeConfig.isAll ? 'ALL' : 'PARTIAL',
            value: valueList
          }
        });
      }
      if (key === 'loan.amount.control') {
        let loanAmountConfig = JSON.parse(propertyMap[key]);
        this.setState({
          controlWays: loanAmountConfig.controlWays,
          singleBottom: isNaN(loanAmountConfig.singleBottom) ? 0 : loanAmountConfig.singleBottom,
          singleTop: isNaN(loanAmountConfig.singleTop) ? 100 : loanAmountConfig.singleTop
        });
      }
    }
  };

  initPriorityValue = () => {
    const { form } = this.context;
    let priorityValue, priorityRangeValue;
    switch (form.fromType) {
      case 1:
        priorityValue = {
          levelCode: "COMPANY",
          levelOrgId: form.companyOID,
          levelOrgName: form.companyName
        };
        priorityRangeValue = {
          id: form.companyId,
          companyOID: form.companyOID,
          name: form.companyName,
          setOfBooksId: form.setOfBooksId
        };
        break;
      case 2:
        priorityValue = {
          levelCode: "SET_OF_BOOK",
          levelOrgId: form.setOfBooksId,
          levelOrgName: form.setOfBooksName
        };
        form.customFormCompanyRequest.visibleCompanyScope === '2' &&
        (priorityValue.distribution = {companies: form.customFormCompanyRequest.companyList});
        priorityRangeValue = {
          setOfBooksId: form.setOfBooksId,
          setOfBooksName: form.setOfBooksName
        };
        break;
      case 3:
        priorityValue = {
          levelCode: "TENANT",
          levelOrgId: form.tenantId,
          levelOrgName: form.tenantName
        };
        priorityRangeValue = {
          id: form.tenantId,
          tenantName: form.tenantName
        };
        break;
    }
    this.setState({priorityValue, priorityRangeValue});
  };

  handleStatusChange = (value, key) => {
    this.setState({
      [key]: value
    });
  };

  handleChangeAmount = (value, key) => {
    if (!isNaN(value) && value !== null && value !== undefined && value !== '') {
      this.setState({
        [key]: value
      });
    } else {
      if (key === 'singleBottom') {
        this.setState({[key]: 0});
      }
      if (key === 'singleTop') {
        this.setState({[key]: 100});
      }
    }
  };

  handleChangeNumberRange = (value) => {
    this.handleChangeAmount(value[0], 'singleBottom');
    this.handleChangeAmount(value[1], 'singleTop');
  };

  //value为true 说明要刷新列表，为event点击事件时不做刷新
  goBack = value => {
    const { close } = this.context;
    if (close) {
      close(value);
    } else {
      this.context.router.push(this.formList.url);
    }
  };

  handleSave = () => {
    const { formOID } = this.context;
    const { refreshBase } = this.props;
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err && this.validateData(values)) {
        let params = this.processValue(values);
        this.setState({loading: true});
        formService.saveNewForm(params).then(res => {
          this.setState({loading: false});
          message.success(messages('common.save.success',{arg1: res.data.formName})/*{arg1} 保存成功*/);
          refreshBase(formOID, 'property');
        }).catch((err) => {
          this.setState({loading: false});
          errorMessage(err.response);
        });
      }
    });
  };

  validateData = (values) => {
    const { formType } = this.context;
    const { form } = this.state;
    const { isHasLoanRelated, relatedFormList, rangeLoanTypeValue, loanTypeDefaultSelectedList, vendorTypeScope,
      controlWays, singleBottom, singleTop } = this.state;
    if (isHasLoanRelated && !relatedFormList.length) {
      message.error(messages('request-2.key15')/*请选择关联的申请单*/);//请选择关联的申请单
      return false;
    }
    if ( isHasLoanRelated && controlWays.indexOf('single') > -1 && (
        singleBottom < 0 || singleBottom > 100 || singleTop < 0 || singleTop > 100
      )) {
      message.error(messages('request-2.key355')/*请正确填写单笔金额管控范围（0.00～100.00）*/);
      return false;
    }
    if (
      (!form.loanTypesDTO || (form.loanTypesDTO.visibleScope !== 1004 && form.loanTypesDTO.visibleScope !== 1005))) {
      if (!rangeLoanTypeValue.range) {
        message.error(messages('request-2.key356')/*请选择借款类型*/);
        return false;
      }
      //借款类型选择部分类型时，默认值需要包含在所选类型中
      if ((rangeLoanTypeValue.range === 'PARTIAL' || rangeLoanTypeValue.range === 'CUSTOMIZE') &&
        !formUtil.isContainDefault(rangeLoanTypeValue.value, (loanTypeDefaultSelectedList[0] || {}), 'id')) {
        message.error(messages('request-2.key19')/*默认值需包含于已选择的部分类型*/);
        return false;
      }
    }
    if (formType === 2006 && values.payeeType.indexOf('2') > -1 && vendorTypeScope.range === 'PARTIAL' && !vendorTypeScope.value.length) {
      message.error(messages('request-2.key113')/*请选择供应商类型*/);
      return false;
    }
    return true;
  };

  processValue = values => {
    const { formOID } = this.context;
    const { form } = this.state;
    let params = {
      ...form,
      customFormFields: form.customFormFields
    };
    //处理借款类型
    if ((!form.loanTypesDTO || (form.loanTypesDTO.visibleScope !== 1004 && form.loanTypesDTO.visibleScope !== 1005))) {
      params.loanTypesDTO = this.processLoanTypeParams();
      if (formOID) {
        params.loanTypesDTO.entityOID = formOID;
      }
    }
    //处理表单属性
    params.customFormPropertyMap = this.processPropertyMap(values);
    return params;
  };

  //处理借款类型params
  processLoanTypeParams = () => {
    const { rangeLoanTypeValue, loanTypeDefaultSelectedList } = this.state;
    let params = {};
    params.visibleScope = 1001;
    if (rangeLoanTypeValue.range === 'DEFAULT') {
      params.visibleScope = 1003;
    }
    if (rangeLoanTypeValue.range === 'CUSTOMIZE' || rangeLoanTypeValue.range === 'PARTIAL') {
      params.visibleScope = 1002;
    }
    params.loanTypeIds = [];
    rangeLoanTypeValue.value.map(selected => {
      params.loanTypeIds.push(selected.id);
    });
    params.defaultLoanTypeId = loanTypeDefaultSelectedList.length ? loanTypeDefaultSelectedList[0].id : null;
    return params;
  };

  //处理表单属性
  processPropertyMap = (values) => {
    const { formType } = this.context;
    const { contractEnable, outApplicationAmount, isReference, relatedFormList, isHasLoanRelated, addVenMaster,
      multiLoanEnable, contractRequired, vendorTypeScope, controlWays, singleBottom, singleTop } = this.state;
    let propertyMap = {};
    //借款单表单属性
    propertyMap['loan.bill.pay.type'] = values.paymentType;
    propertyMap['loan.application.participation.repay.enable'] = values.associatePayExpense;
    formType === 2006 && (propertyMap['loan.bill.pay.method.changeable'] = values.loanType);
    propertyMap['loan.property.associated.contract.enabled'] = contractEnable;
    propertyMap['associate.contract.required'] = contractEnable ? contractRequired : false;
    propertyMap['loan.amount.control'] = JSON.stringify({
      controlWays,
      singleBottom,
      singleTop,
      controlType: 'forbidden' //目前只有禁止的情况
    });
    let relatedFormOIDList = [];
    relatedFormList.map(relatedForm => {
      relatedFormOIDList.push(relatedForm.formOID);
    });
    propertyMap['loan.application.configuration'] = JSON.stringify({
      notLink: !isHasLoanRelated,
      outApplicationAmount,
      isReference: isHasLoanRelated ? isReference : false,
      applicationFormOID: isHasLoanRelated ? relatedFormOIDList: []
    });
    if (formType === 2006) {
      propertyMap['multi.loan'] = multiLoanEnable;
      propertyMap['payee.type'] = values.payeeType.join(',');
      let propertyValue = {
        isAll: vendorTypeScope.range === 'ALL',
        typeList: vendorTypeScope.value.map(item => item.id)
      };
      propertyMap['payee.vendor.type'] = JSON.stringify(propertyValue);
    }
    propertyMap['document.venmasteradd.enable'] = addVenMaster;
    return propertyMap;
  };

  handleChangePayeeType = (values) => {
    const { isShowVendorType } = this.state;
    if (!isShowVendorType && values.indexOf('2') > -1) {
      this.setState({vendorTypeScope: {range: 'ALL', value: []}});
    }

    if (values.indexOf('2') > -1) {
      this.setState({isShowVendorType: true});
    } else {
      this.setState({isShowVendorType: false});
    }
  };

  render() {
    const { formType } = this.context;
    const { getFieldDecorator, getFieldValue } = this.props.form;
    const { loading, disabled, loanDisabled, setOfBooksId, priorityValue, paymentTypeList, rangeLoanTypeValue,
      loanTypeDefaultSelectedList, isHasLoanRelated, relatedFormLoading, relatedFormList, isReference, controlWays,
      singleBottom, singleTop, contractEnable, contractRequired, multiLoanEnable, vendorTypeScope, addVenMaster, form
    } = this.state;
    const formItemLayout = {
      labelCol: {span: 4},
      wrapperCol: {span: 8, offset: 1},
    };
    let loanTypeChooserItem = deepFullCopy(chooserData['available_loan_type']);
    return (
      <div className="form-new-edit new-form form-detail-base">
        <Spin spinning={loading}>
          <Form>
            <FormItem {...formItemLayout} label={messages('request-2.key34')/*付款方式类型*/}>
              {getFieldDecorator('paymentType', {
                rules: [
                  {
                    required: true,
                    message: messages('common.select')/*请选择*/
                  }
                ],
                initialValue: undefined
              })(
                <Select
                  disabled={disabled}
                  placeholder={messages('common.select')/*请选择*/}
                  defaultActiveFirstOption={false}
                  showArrow={true}
                  getPopupContainer={triggerNode => triggerNode.parentNode}>
                  {paymentTypeList.map((option) => {
                    return <Option key={option.key}>{option.label}</Option>
                  })}
                </Select>
              )}
            </FormItem>
            {
              formType === 2006 && (
                <div className="special-height">
                  <FormItem {...formItemLayout} label={messages('request-2.key447')/*允许员工选择付款方式*/}>
                    {getFieldDecorator('loanType', {
                      initialValue: false
                    })(
                      <RadioGroup disabled={disabled || loanDisabled}>
                        <Radio value={true}>{messages('common.yes')/*是*/}</Radio>
                        <Radio style={{marginLeft: 50}} value={false}>{messages('common.no')/*否*/}</Radio>
                      </RadioGroup>
                    )}
                  </FormItem>
                </div>
              )
            }
            <FormItem {...formItemLayout} label={messages('request-2.key152')/*借款类型*/}>
              <div className="normal-width">
                <AllocationLoanType
                  onChange={value => this.handleStatusChange(value, 'rangeLoanTypeValue')}
                  setOfBooksId={setOfBooksId}
                  value={rangeLoanTypeValue}
                  parser={value => ({range: value.range, value: value.value || []})}
                  hidden={formType === 2005 ? ['ALL', 'PARTIAL'] : ['DEFAULT', 'CUSTOMIZE']}
                  componentProps={{
                    'PARTIAL': {
                      showNumber: formType === 2006,
                      single: formType === 2005
                    },
                    'CUSTOMIZE': {
                      showNumber: formType === 2006,
                      single: formType === 2005
                    }
                  }}
                  disabled={disabled || loanDisabled}
                  fromType={form.fromType}
                />
                {
                  form.fromType !== 3 && (
                    <Row style={{marginTop: 12, marginBottom: 0}}>
                      <Col span={6}>
                        {messages('request-2.key36')/*默认值：*/}
                      </Col>
                      <Col span={18}>
                        <Chooser
                          placeholder={messages('common.select')/*请选择*/}
                          labelKey='description'
                          valueKey='id'
                          selectorItem={loanTypeChooserItem}
                          listExtraParams={{
                            isIncludeSys: false,
                            setOfBooksId
                          }}
                          disabled={disabled || loanDisabled || !setOfBooksId}
                          onChange={value => this.handleStatusChange(value, 'loanTypeDefaultSelectedList')}
                          value={loanTypeDefaultSelectedList}
                          showNumber={false}
                          single={true}
                        />
                      </Col>
                    </Row>
                  )
                }
              </div>
            </FormItem>
            <div className="special-height">
              <FormItem {...formItemLayout} label={messages('request-2.key43')/*报销单还款*/}>
                {getFieldDecorator('associatePayExpense', {
                  initialValue: true
                })(
                  <RadioGroup disabled={disabled || loanDisabled}>
                    <Radio value={true}>{messages('common.yes')/*是*/}</Radio>
                    <Radio style={{marginLeft: 50}} value={false}>{messages('common.no')/*否*/}</Radio>
                  </RadioGroup>
                )}
              </FormItem>
            </div>
            <div className="special-height group-line">
              <FormItem {...formItemLayout} label={messages('request-2.key44')/*关联申请单*/}>
                <RadioGroup
                  disabled={disabled || loanDisabled}
                  value={isHasLoanRelated}
                  onChange={e => this.handleStatusChange(e.target.value, 'isHasLoanRelated')}
                >
                  <Radio value={true}>{messages('request-2.key32')/*关联*/}</Radio>
                  <Radio value={false} style={{marginLeft: 50}}>{messages('request-2.key46')/*不关联*/}</Radio>
                </RadioGroup>
                <div style={{color: '#989898'}}>{messages('request-2.key358')/*选择关联，则借款单创建时，可关联申请单*/}</div>
                {isHasLoanRelated && (
                  <div className="normal-width">
                    <Row style={{margin: '12px 0'}}>
                      <Col span={4}>{messages('request-2.key50')/*关联对象*/}</Col>
                      <Col span={19} offset={1}>
                        <Chooser
                          placeholder={messages('common.select')/*请选择*/}
                          type='available_related_form'
                          labelKey='formName'
                          valueKey='formOID'
                          disabled={relatedFormLoading || disabled || loanDisabled || !priorityValue.levelOrgId}
                          onChange={value => this.handleStatusChange(value, 'relatedFormList')}
                          value={relatedFormList}
                          listExtraParams={{
                            setOfBooksId: priorityValue.levelCode === 'SET_OF_BOOK' ? priorityValue.levelOrgId : undefined,
                            companyOID: priorityValue.levelCode === 'COMPANY' ? priorityValue.levelOrgId : undefined
                          }}
                          showNumber
                        />
                      </Col>
                    </Row>
                    <Row style={{marginBottom: 0}}>
                      <Col span={4} style={{lineHeight: '31px'}}>{messages('request-2.key51')/*关联控制*/}</Col>
                      <Col span={19} offset={1}>
                        <RadioGroup
                          disabled={disabled || loanDisabled}
                          value={isReference}
                          onChange={e => this.handleStatusChange(e.target.value, 'isReference')}
                        >
                          <Radio value={true}>{messages('request-2.key52')/*关联必填*/}</Radio>
                          <Radio style={{marginLeft: 50}} value={false}>{messages('request-2.key53')/*关联选填*/}</Radio>
                        </RadioGroup>
                      </Col>
                    </Row>
                  </div>
                )}
              </FormItem>
              {isHasLoanRelated && (
                <FormItem {...formItemLayout} label={messages('request-2.key359')/*借款金额管控*/}>
                  <CheckboxGroup value={controlWays} disabled={disabled || loanDisabled} onChange={value => this.handleStatusChange(value, 'controlWays')}>
                    <Row>
                      <Col span={8}><Checkbox value={"total"}>{messages('request-2.key360')/*总金额不管控*/}</Checkbox></Col>
                      <Col span={8}><Checkbox value={"single"}>{messages('request-2.key361')/*单笔金额管控*/}</Checkbox></Col>
                    </Row>
                  </CheckboxGroup>
                  {controlWays.indexOf('single') > -1 && (
                    <Row style={{marginTop: 12}}>
                      <Col span={8}>
                        <span style={{fontSize: 14, color: '#f5222d', fontFamily: 'SimSun'}}>*&nbsp;</span>{messages('request-2.key362')/*单笔金额范围：*/}
                      </Col>
                      <Col span={15}>
                        <NumberRange value={[singleBottom, singleTop]} allowInputZero onChange={value => this.handleChangeNumberRange(value)}/>
                      </Col>
                      <Col span={1}>&nbsp;%</Col>
                    </Row>
                  )}
                </FormItem>
              )}
            </div>
            {formType === 2006 && (
              <div className="special-height">
                <FormItem {...formItemLayout} label={messages('request-2.key37')/*关联合同*/}>
                  <RadioGroup
                    disabled={disabled || loanDisabled}
                    value={contractEnable}
                    onChange={e => this.handleStatusChange(e.target.value, 'contractEnable')}
                  >
                    <Radio value={true}>{messages('request-2.key32')/*关联*/}</Radio>
                    <Radio value={false} style={{marginLeft: 50}}>{messages('request-2.key46')/*不关联*/}</Radio>
                  </RadioGroup>
                  <div style={{color: '#989898'}}>{messages('request-2.key58')/*员工填写借款单时，可关联合同付款计划*/}</div>
                </FormItem>
                {contractEnable && (
                  <FormItem {...formItemLayout} label={messages('request-2.key325')/*关联合同必填*/}>
                    <RadioGroup
                      disabled={disabled || loanDisabled}
                      value={contractRequired}
                      onChange={e => this.handleStatusChange(e.target.value, 'contractRequired')}
                    >
                      <Radio value={true}>{messages('request-2.key326')/*必填*/}</Radio>
                      <Radio style={{marginLeft: 50}} value={false}>{messages('request-2.key327')/*不必填*/}</Radio>
                    </RadioGroup>
                  </FormItem>
                )}
              </div>
            )}
            {formType === 2006 && (
              <div className="special-height">
                <FormItem {...formItemLayout} label={messages('request-2.key39')/*多行借款*/}>
                  <RadioGroup
                    disabled={disabled || loanDisabled}
                    value={multiLoanEnable}
                    onChange={e => this.handleStatusChange(e.target.value, 'multiLoanEnable')}
                  >
                    <Radio value={true}>{messages('common.yes')/*是*/}</Radio>
                    <Radio style={{marginLeft: 50}} value={false}>{messages('common.no')/*否*/}</Radio>
                  </RadioGroup>
                </FormItem>
              </div>
            )}
            {formType === 2006 && (
              <div className="group-line">
                <FormItem {...formItemLayout} label={messages('request-2.key40')/*收款方类型*/}>
                  <div className="normal-width">
                    {getFieldDecorator('payeeType', {
                      rules: [
                        {
                          required: true,
                          message: messages('common.select')/*请选择*/  //请选择
                        }
                      ],
                      initialValue: ["1", "2"]
                    })(
                      <CheckboxGroup disabled={disabled || loanDisabled} onChange={this.handleChangePayeeType}>
                        <Row>
                          <Col span={8}><Checkbox value={"1"}>{messages('request-2.key41')/*员工*/}</Checkbox></Col>
                          <Col span={8}><Checkbox value={"2"}>{messages('request-2.key42')/*供应商*/}</Checkbox></Col>
                        </Row>
                      </CheckboxGroup>
                    )}
                    {getFieldValue('payeeType').indexOf('2') > -1 && (
                      <Row style={{marginTop: '5px', marginBottom: 0}}>
                        <Col span={6}>
                          <span style={{fontSize: 14, color: '#f5222d', fontFamily: 'SimSun'}}>*&nbsp;</span>{messages('request-2.key363')/*供应商类型:*/}
                        </Col>
                        <Col span={18}>
                          <AllocationVendorType
                            disabled={disabled || loanDisabled}
                            value={vendorTypeScope}
                            parser={value => ({range: value.range, value: value.value || []})}
                            onChange={value => this.handleStatusChange(value, 'vendorTypeScope')}
                            componentProps={{
                              'PARTIAL': {
                                showDetail: false,
                                listExtraParams:{
                                  isEnabled: true
                                }
                              }
                            }}
                          />
                        </Col>
                      </Row>
                    )}
                  </div>
                </FormItem>
              </div>
            )}
            <div className="special-height">
              <FormItem {...formItemLayout} label={messages('request-2.key350')/*员工创建供应商*/}>
                <RadioGroup
                  disabled={disabled || loanDisabled}
                  value={addVenMaster}
                  onChange={e => this.handleStatusChange(e.target.value, 'addVenMaster')}
                >
                  <Radio style={{marginRight: 50}} value="false">{messages('request-2.key56')/*不可创建*/}</Radio>
                  <Radio style={{marginRight: 50}} value="true">{messages('request-2.key351')/*可创建：供应商+银行账号*/}</Radio>
                  <Radio value="bankOnly">{messages('request-2.key352')/*可创建：银行账号*/}</Radio>
                </RadioGroup>
              </FormItem>
            </div>
          </Form>
        </Spin>
        <Affix offsetBottom={0} className="bottom-bar">
          {!disabled && (
            <Button type="primary" loading={loading} onClick={this.handleSave}>{messages('common.ok')/*确定*/}</Button>
          )}
          <Button style={{marginLeft: 15}} onClick={() => this.goBack(true)}>{messages('common.back')/*返回*/}</Button>
        </Affix>
      </div>
    )
  }
}

LoanProperty.propTypes = {
  refreshBase: PropTypes.func
};

function mapStateToProps(state) {
  return {
    currentMenuPermission: state.main.currentMenuPermission,
    profile: state.login.profile
  }
}

LoanProperty.contextTypes = {
  formType: PropTypes.any,
  formOID: PropTypes.string,
  form: PropTypes.object,
  router: PropTypes.object,
  close: PropTypes.any
};

const WrappedLoanProperty = Form.create()(LoanProperty);

export default connect(mapStateToProps)(WrappedLoanProperty)
